import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'serial_port_method_channel.dart';

abstract class SerialPortPlatform extends PlatformInterface {
  /// Constructs a SerialPortPlatform.
  SerialPortPlatform() : super(token: _token);

  static final Object _token = Object();

  static SerialPortPlatform _instance = MethodChannelSerialPort();

  /// The default instance of [SerialPortPlatform] to use.
  ///
  /// Defaults to [MethodChannelSerialPort].
  static SerialPortPlatform get instance => _instance;

  /// Platform-specific implementations should set this with their own
  /// platform-specific class that extends [SerialPortPlatform] when
  /// they register themselves.
  static set instance(SerialPortPlatform instance) {
    PlatformInterface.verifyToken(instance, _token);
    _instance = instance;
  }

  Future<String?> getPlatformVersion() {
    throw UnimplementedError('platformVersion() has not been implemented.');
  }

  Future<bool?> start(String device, int baudrate) {
    throw UnimplementedError('start() has not been implemented.');
  }

  Future<void> setLog(bool value) {
    throw UnimplementedError('setLog() has not been implemented.');
  }

  Future<bool?> close() {
    throw UnimplementedError('close() has not been implemented.');
  }

  /// Returns a Stream of SerialPortData changes.
  Stream<String> get onSerialPortDataChanged {
    throw UnimplementedError(
        'get onSerialPortDataChanged has not been implemented.');
  }
}
